package org.example.handler;import io.netty.channel.ChannelHandler;import io.netty.channel.ChannelHandlerContext;import io.netty.channel.ChannelInboundHandlerAdapter;import io.netty.handler.timeout.IdleState;import io.netty.handler.timeout.IdleStateEvent;public class ReadDataHandler extends ChannelInboundHandlerAdapter {    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {        System.out.println("heartBeat 心跳包" + msg);    }    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {        ctx.close();    }    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {        if (evt instanceof IdleStateEvent) {            IdleState state = ((IdleStateEvent) evt).state();            if (state == IdleState.READER_IDLE) {                ctx.disconnect();            }        } else {            super.userEventTriggered(ctx, evt);        }    }}